package com.heny.demo.mybatis;

import com.baomidou.mybatisplus.extension.plugins.handler.TableNameHandler;
import com.heny.demo.dbutils.DynamicTableContext;

public class DeviceHistoryDataTableNameHandler implements TableNameHandler {
    @Override
    public String dynamicTableName(String sql, String originalTableName) {
        String dynamicTableName = DynamicTableContext.getTableName();
        if (dynamicTableName != null) {
            return dynamicTableName; // 返回动态表名
        }
        // TODO 线程中午tableName时返回原始表名
        return originalTableName;
//        throw new CommonException(CommonErrorCode.SYSTEM_ERROR,"未设置动态表名");
    }
}